<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>产品</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<style>
		html{ padding: 10px}
	</style>
</head>
<body class="childrenBody">
<blockquote class="layui-elem-quote">供应添加</blockquote>



	<div class="layui-form-item">
		<label class="layui-form-label">产品名称</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input newsName"   name="name" id="Name" lay-verify="required" placeholder="请输入产品名称">
		</div>
	</div>


	<div class="layui-form-item">



		

	</div>

	<div class="layui-form-item">


		
		<div class="layui-inline" style="margin-bottom: 20px;">
			<label class="layui-form-label">最小价格</label>
			<div class="layui-input-inline">
				<input type="number" name="price"  class="layui-input newsAuthor" id="MinPrice" placeholder="请输入价格">
			</div>
		</div>
		<div class="layui-inline" style="margin-bottom: 20px;">
			<label class="layui-form-label">最大价格</label>
			<div class="layui-input-inline">
				<input type="number" name="price1"  class="layui-input newsAuthor" id="MaxPrice"  placeholder="请输入价格">
			</div>
		</div>
         <div class="layui-form-item">
		 <label class="layui-form-label">产品规格</label>
		<div class="layui-input-inline">
				<select class="newsLook" name="cate" id="Unit" lay-filter="browseLook" style="height: 38px;line-height: 38px;border: none;margin-bottom: 20px;">
					{volist name="list" id="vo"}
					<option value="{$vo.unid}">{$vo.type}</option>
					{/volist}
				</select>
			</div>
			 <div class="layui-form-item">
		 <label class="layui-form-label">地区</label>
		<div class="layui-input-inline" style="width: 300px;">
				<select id="s_province" name="s_province" style="height: 38px;line-height: 38px;border: none;"></select>  
                <select id="s_city" name="s_city" style="height: 38px;line-height: 38px;border: none;"></select>  
                <select id="s_county" name="s_county" style="height: 38px;line-height: 38px;border: none;"></select>
			</div>

	</div>


	</div>
    
		{volist name="info" id="vo"}
		<input type="hidden" name="tel" value="{$vo.tel}"  class="layui-input newsAuthor" id="Mobile">
		<input type="hidden" name="tel" value="{$vo.qyfr}"  class="layui-input newsAuthor" id="AccountName">
		<input type="hidden" name="tel" value="{$vo.id}"  class="layui-input newsAuthor" id="AccountID">
		{/volist}
<input type="hidden" name="tid" value="{$t.id}">
	<div class="layui-form-item">
		<label class="layui-form-label">缩略图400*400</label>
		<div class="layui-input-block">

			{empty name="t.pic" }
			<img src="{:_STATIC}/img/nopic.jpg" width="200" height="200" id="pic" />
			{else /}
			<img src="{$t.pic}" width="200" height="200" id="pic" />

			{/empty}
		</div>

		<input name="pic" type="hidden" id="picval" value="{$t.pic}" />
	</div>


	<div class="layui-form-item">
		<label class="layui-form-label">产品详情</label>
		<div class="layui-input-block">
				<textarea name="content" id="news_content" style="height: 600px">


					{$t.content}
				</textarea>
		</div>
	</div>
	
	
	<div class="layui-form-item">
		<div class="layui-input-block">
			<button class="layui-btn" type="button"  lay-submit="" onclick="verify()" >立即提交</button>
			<button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
	</div>
{:jq()}
{:layui()}
{:ue()}
<script type="text/javascript" src="{:_SKIN}/user/js/area.js"></script>
<script type="text/javascript">_init_area();</script>
<script type="text/javascript">



    layui.upload.render({
        elem: '#pic'
        ,url: "{:url('api/upload/qiniu')}"
        ,size: 500000 //限制文件大小，单位 KB
        ,done: function(res){
        	if(res.code==200){
        		parent.layer.msg('上传成功');


             $("#picval").val(res.url);
             $("#pic").attr('src',res.url);

        	}
           
        }
    });
    var ue = UE.getEditor('news_content',{

        height:700
    });

    layui.form.on('submit(addNews)', function(data){
          
          $.post(' ',data.field,function(res){

                if(res.code==200){

                parent.layer.alert('保存成功，点确定继续上传',function(){

                     parent.layer.closeAll();
                     window.location.reload();

                });

                }


          });

        console.log(JSON.stringify(data.field));
        return false;
    });


</script> 
<script>
	 var ue = UE.getEditor('news_content',{

        height:700
    });
	function verify()
	{

		//产品名称
		var name = $('#Name').val();
		//最小价格
		var MinPrice = $('#MinPrice').val();
		//最大价格
		var MaxPrice = $('#MaxPrice').val();
		//联系电话
		var tel = $('#Mobile').val();
		//联系人
		var AccountName = $('#AccountName').val();
		//产品规格
		var Specification = $('#Unit').val();
		//店铺id
		var id = $('#AccountID').val();
		//获取省
		var s_province = $('#s_province').val();
		//获取市
		var s_city = $('#s_city').val();
		//获取县
		var s_county = $('#s_county').val();
		//产品详情
		//获取缩略图路径
		var picval = $("#pic").attr('src');
		var content = UE.getEditor('news_content').getContent();
			//alert(content);

			$.ajax({
			type:"POST",
			url:"{:url('supply/addinfo')}",
			dataType: 'json',
			data:{Name:name,MinPrice:MinPrice,MaxPrice:MaxPrice,Mobile:tel,AccountName:AccountName,Unit:Specification,news_content:content,AccountID:id,s_province:s_province,s_city:s_city,s_county:s_county,picval:picval}

		})
	}
</script>
</body>
</html>